

<template>
    <rm-layout-top splitcolor="white" :splitwidth=5 :fixsize=35 :canDrag=false>
        <template v-slot:fix>
            <div style="height:35px;border:1px solid #CCC;padding:4px">
                <el-row>
                    <el-col :span="12">
                        <div class="grid-content bg-purple"> <span class="remind_class">以下申请单计价失败，请予以关注！</span></div>
                    </el-col>
                    <el-col :span="4">
                        <div class="grid-content bg-purple">
                            <el-checkbox v-model="remindobj.chkremind" true-label="1" false-label="0" @change="chkremindChange">不再提醒</el-checkbox>
                        </div>
                    </el-col>
                    <el-col :span="8">
                        <div class="grid-content bg-purple-light">
                            <!-- <el-button style="width:72px" @click.native="btnRefresh">刷新</el-button> -->
                            <el-button style="width:72px" @click.native="btnRehandle">重新处理</el-button>
                            <el-button style="width:72px" @click.native="btnRptAdmin" v-if="isrptadmin=='1'">上报管理员</el-button>
                            <el-button style="width:72px" @click.native="btnClose">退出</el-button>
                        </div>
                    </el-col>

                </el-row>
            </div>
        </template>
        <div style="height:100%">
            <vxe-table show-overflow ref="xTable" :data.sync="ReqChargeAlertData" height="auto" width="100%" border size="mini" :select-config="{ reserve: true }" highlight-current-row show-header-overflow resizable header-align="center" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true, showIcon: false }" key="1" :cell-class-name="cellclassname" class="mytable-style" @current-change="currentChangeEvent" :loading="loading">
                <vxe-table-column field="recieve_dt" title="接收时间" width="120" :formatter="['toDateString', 'yyyy-MM-dd HH:mm:ss']" align="center"></vxe-table-column>
                <vxe-table-column field="pat_no" title="病历号" width="80"></vxe-table-column>
                <vxe-table-column field="pat_name" title="姓名" width="60"></vxe-table-column>
                <vxe-table-column field="pat_sex" title="性别" width="50" align="center">
                    <template v-slot="{row}">
                        <div>{{!!row.pat_sex?(row.pat_sex=='1'?'男':'女'):"未知"}}</div>
                    </template>
                </vxe-table-column>
                <vxe-table-column field="barcode" title="条码号" width="100"></vxe-table-column>
                <vxe-table-column field="emer_flag" title="加急" width="50" align="center">
                    <template v-slot="{row}">
                        <el-checkbox true-label="1" false-label="0" v-model="row.alterflag" disabled></el-checkbox>
                    </template>
                </vxe-table-column>
                <vxe-table-column field="sample_items" title="申请项目（简称，部分）" width="150"></vxe-table-column>
                <vxe-table-column field="chargefailmsg" title="计价相关信息或失败相关信息" width="170"></vxe-table-column>
                <vxe-table-column field="chargefailcnt" title="失败次数" width="70" align="center"></vxe-table-column>
                <vxe-table-column field="rptunitnamesampleno" title="报告单元 - 样本号" width="200"></vxe-table-column>
                <vxe-table-column field="specimen_name" title="标本类型" width="70"></vxe-table-column>
                <vxe-table-column field="base_amount" title="基础价格" width="60" align="right" header-align="center"></vxe-table-column>
                <vxe-table-column field="amount" title="金额" width="70" align="right" header-align="center"></vxe-table-column>
                <vxe-table-column field="req_deptname" title="申请科室" width="100"></vxe-table-column>
                <vxe-table-column field="req_wardname" title="病区" width="100"></vxe-table-column>
                <vxe-table-column field="perform_deptname" title="执行科室" width="100"></vxe-table-column>
                <vxe-table-column field="req_bedno" title="床号" width="70" align="center"></vxe-table-column>
                <vxe-table-column field="req_docname" title="申请医生" width="70" align="center"></vxe-table-column>
                <vxe-table-column field="req_dt" title="申请时间" width="120"></vxe-table-column>
                <vxe-table-column field="reqtypename" title="申请业务" width="60"></vxe-table-column>
                <vxe-table-column field="labadd" title="实验室新增" width="80" align="center">
                    <template v-slot="{row}">
                        <el-checkbox true-label="1" false-label="0" v-model="row.alterflag" disabled></el-checkbox>
                    </template>
                </vxe-table-column>
                <vxe-table-column field="req_stat" title="状态" width="60"  align="center"></vxe-table-column>
                <vxe-table-column field="charge_flag" title="计价标志" width="60"  align="center"></vxe-table-column>
                <vxe-table-column field="recieve_username" title="接收人" width="60"></vxe-table-column>
                <vxe-table-column field="recieve_host" title="检验科接收电脑" width="120"></vxe-table-column>
                <vxe-table-column field="reqsource" title="申请单来源" width="80"></vxe-table-column>
                <template v-slot:fix>
                    <div style="font-size:17px;padding-top:3px;background-color:#fff;text-align:center;font-weight:bold;color:blue">共 {{datacnt}} 条</div>
                </template>
            </vxe-table>
        </div>
        <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="请选择管理员" :visible.sync="rptadminDialog">
            <rm-pop-common @change="SelectRptuser" @cancel="rptadminDialog=false;" datatype="reportuseradmin" ></rm-pop-common>
        </el-dialog>
    </rm-layout-top>


</template>

<script type="text/javascript">
export default {
    name: "rm_devalertinfo",
    props: {
        tabledata: { type: Array },
        params: { type: Object },
        isrptadmin : { type: String },
    },
    data() {
        return {
            ReqChargeAlertData: this.tabledata,
            loading: false,
            rptadminDialog:false,
            remindobj: { barcodes: "", confirmusername: "", chkremind: "0", isfirstconfirm: false },
        };
    },
    created() {
        console.log("2221",this.params);
        console.log("isrptadmin",this.isrptadmin);

    },
    computed: {
        datacnt() {
            return this.ReqChargeAlertData.length;
        },
    },
    watch: {},
    mounted() {
        this.setcurRow(this.ReqChargeAlertData);
    },
    methods: {
        //获取自动提醒弹窗的选中行
        currentChangeEvent({ row, column }) {
            // this.remindobj.selrow = row;
        },
        //不再提醒，记录下点击时的时间，该时间之前的不再显示
        chkremindChange() {
            if (this.remindobj.chkremind == "1") {
                this.$ddldata.msgparm.localReqChargedt = this.$pub.InitDateTime();
            } else {
                this.$ddldata.msgparm.localReqChargedt = "";
            }
        },
        //自动提醒弹窗列表的颜色
        cellclassname({ row, column }) {
            if (column.property == "barcode") {
                return "col-blue";
            } else if (column.property == "chargefailmsg") {
                return "col-red";
            }
        },
        //上报管理员
        btnRptAdmin(){
            this.remindobj.barcodes = "";
            this.ReqChargeAlertData.forEach((item) => {
                if (!this.remindobj.barcodes) this.remindobj.barcodes = item.barcode;
                else this.remindobj.barcodes += "," + item.barcode;
            });
            if(this.remindobj.barcodes=="")
            {
                this.$alert("没有可上报的数据！", "提示");
                return false;
            }else{
                this.rptadminDialog=true;
            }
        },
        SelectRptuser(code,name){
            if(code && name){
                this.$tool
                .request({
                    url: "ucent/handlemsg",
                    method: "post",
                    data: {
                        action: "chargeRptAdmin",
                        barcodes: this.remindobj.barcodes,
                        userno:code,
                        username:name
                    },
                })
                .then((res) => {
                    if(res.errcode == "1"){
                        this.$pub.message(this, "已成功上报管理员" + this.datacnt + "条申请单计价失败消息！", "success");
                        this.btnClose();
                    }else{
                        this.$alert(res.errmsg, "提示");
                    }
                })
            }
            this.rptadminDialog=false;

        },
        //重新处理(更新失败次数为0)
        btnRehandle() {
            this.remindobj.barcodes = "";
            this.ReqChargeAlertData.forEach((item) => {
                if (!this.remindobj.barcodes) this.remindobj.barcodes = item.barcode;
                else this.remindobj.barcodes += "," + item.barcode;
            });
            this.$tool
                .request({
                    url: "ucent/handlemsg",
                    method: "post",
                    data: {
                        action: "chargeRehandle",
                        barcodes: this.remindobj.barcodes,
                    },
                })
                .then((res) => {
                    if (res.errcode == "1") {
                        this.$pub.message(this, "已成功处理" + this.datacnt + "条申请单计价失败消息！", "success");
                        this.btnClose();
                       // this.btnRefresh();
                    } else {
                        this.$alert(res.errmsg, "提示");
                    }
                })
                .catch((e) => {
                    this.$alert(e, "提示");
                });
        },
        //刷新仪器危急值
        btnRefresh() {
            this.loading = true;
            this.$tool
                .request({
                    url: "ucent/alertmsg",
                    method: "post",
                    data: {
                        params: this.params.paramlist,
                    },
                })
                .then((res) => {
                    this.ReqChargeAlertData = res.data;
                    if (this.$refs.xTable && res.data.length > 0) this.setcurRow(res.data[0]);
                    this.loading = false;
                })
                .catch((e) => {
                    this.$alert(e, "提示");
                    this.loading = false;
                });
        },
        setcurRow(data) {
            if (this.$refs.xTable && data.length > 0) {
                this.$refs.xTable.setCurrentRow(data[0]);
            }
        },
        //退出
        btnClose() {
            this.$emit("change", "reqcharge",this.params, this.remindobj.chkremind);
        },
    },
};
</Script>

<style scoped>
.remind_class {
    color: rgb(236, 11, 11);
    font-size: 18px;
}
::v-deep .mytable-style .vxe-body--row.row-pink {
    background-color: pink;
    color: rgb(8, 8, 8);
}

::v-deep  .mytable-style .vxe-body--column.col-red {
    background-color: red;
    color: #fff;
}
::v-deep  .mytable-style .vxe-body--column.col-blue {
    background-color: #2db7f5;
    color: #fff;
}
::v-deep .el-checkbox__inner::after {
    border: 2px solid #000000 !important;
    box-sizing: content-box;
    content: "";
    border-left: 0 !important;
    border-top: 0 !important;
    height: 7px;
    left: 4px;
    position: absolute;
    top: 1px;
    transform: rotate(45deg) scaleY(0);
    width: 3px;
    transition: transform 0.15s ease-in 0.05s;
    transform-origin: center;
}
::v-deep .el-checkbox__input.is-disabled + span.el-checkbox__label {
    color: #000000;
    cursor: not-allowed;
}
</style>
